<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8" />
        <title>{:C('PRO_TITLE')} - 重置密码</title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta content="A premium admin dashboard template by mannatthemes" name="description" />
        <meta content="Mannatthemes" name="author" />

        <!-- App favicon -->
        <link rel="shortcut icon" href="__PUBLIC__/assets/images/favicon.ico">

        <!-- App css -->
        <link href="__PUBLIC__/assets/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
        <link href="__PUBLIC__/assets/css/icons.css" rel="stylesheet" type="text/css" />
        <link href="__PUBLIC__/assets/css/metismenu.min.css" rel="stylesheet" type="text/css" />
        <link href="__PUBLIC__/assets/css/style.css" rel="stylesheet" type="text/css" />
        <link href="__PUBLIC__/assets/plugins/toast/jquery.toast.min.css" rel="stylesheet" type="text/css" />

    </head>

    <body class="account-body">

        <!-- Log In page -->
        <div class="row vh-100">
            <div class="col-lg-3  pr-0">
                <div class="card mb-0 shadow-none">
                    <div class="card-body">
                        
                        <div class="px-3">
                            <div class="media">
                                <a href="index.html" class="logo logo-admin"><img src="__PUBLIC__/assets/images/logo-sm.png" height="55" alt="logo" class="my-3"></a>
                                <div class="media-body ml-3 align-self-center">                                                                                                                       
                                    <h4 class="mt-0 mb-1">忘记密码</h4>
                                    <p class="text-muted mb-0">重置密码</p>
                                </div>
                            </div>                            
                            
                            <form id="content" class="form-horizontal my-4" method="POST" action="__ACTION__" aria-label="找回密码">

                                <div class="form-group">
                                    <label for="username">用户名</label>
                                    <div class="input-group mb-3">
                                        <div class="input-group-prepend">
                                            <span class="input-group-text" id="basic-addon1"><i class="mdi mdi-account-outline font-16"></i></span>
                                        </div>
                                        <input type="text" class="form-control"  value="{$username}" readonly>
                                    </div>                                    
                                </div>
    
                                <div class="form-group">
                                    <label for="password">新密码</label>
                                    <div class="input-group mb-3">
                                        <div class="input-group-prepend">
                                            <span class="input-group-text" id="basic-addon2"><i class="mdi mdi-key font-16"></i></span>
                                        </div>
                                        <input type="password" class="form-control" id="password"  name="password" placeholder="新密码">
                                    </div>                                
                                </div>

                                <div class="form-group">
                                    <label for="password">重复新密码</label>
                                    <div class="input-group mb-3">
                                        <div class="input-group-prepend">
                                            <span class="input-group-text" id="basic-addon2"><i class="mdi mdi-key font-16"></i></span>
                                        </div>
                                        <input type="password" class="form-control" id="repassword"  name="repassword" placeholder="重复新密码">
                                    </div>                                
                                </div>
    
    
                                <div class="form-group mb-0 row">
                                    <div class="col-12 mt-2">
                                        <input type="hidden" id="k" name="k" value="{$Think.request.k}" />
                                        <button class="btn btn-primary btn-block waves-effect waves-light send" type="button">密码重置 <i class="mdi mdi-key-change ml-1"></i> </button>
                                    </div>
                                </div>                            
                            </form>
                        </div>
                        
                        <div class="m-3 text-center bg-light p-3 text-primary">
                            <h5 class="">记得密码 ?</h5>
                            <p class="font-13">现在去登录</p>
                            <a href="{:U('login')}" class="btn btn-primary btn-round waves-effect waves-light">立即登录</a>                
                        </div>                        
                    </div>
                </div>
            </div>
            <div class="col-lg-9 p-0 d-flex justify-content-center">
                <div class="accountbg d-flex align-items-center"> 
                    <div class="account-title text-white text-center">
                        <img src="__PUBLIC__/assets/images/logo-sm.png" alt="" class="thumb-sm">
                        <h4 class="mt-3">欢迎使用</h4>
                        <div class="border w-25 mx-auto border-primary"></div>
                        <h1 class="">{:C('PRO_TITLE')}</h1>
                        <p class="font-14 mt-3">没有账号 ? <a href="{:U('register')}" class="text-primary">注册</a></p>
                       
                    </div>
                </div>
            </div>
        </div>
        <!-- End Log In page -->

        <!-- jQuery  -->
        <script src="__PUBLIC__/assets/js/jquery.min.js"></script>
        <script src="__PUBLIC__/assets/js/bootstrap.bundle.min.js"></script>
        <script src="__PUBLIC__/assets/js/metisMenu.min.js"></script>
        <script src="__PUBLIC__/assets/js/waves.min.js"></script>
        <script src="__PUBLIC__/assets/js/jquery.slimscroll.min.js"></script>
        <script src="__PUBLIC__/assets/plugins/toast/jquery.toast.min.js"></script>

        <!-- App js -->
        <script src="__PUBLIC__/assets/js/app.js"></script>
        <script>
            $('.send').on('click', function(){
			var url = "{:U('resetPwd')}";
			var k = $('#k').val();
			var pwd = $.trim($('#password').val());
			var repwd = $.trim($('#repassword').val());
			if(pwd.length == 0){
                notify("error","提示","密码不能为空！");
				return;
			}
			if(pwd !== repwd){
                notify("error","提示","二次输入密码不一致！");
				return;
			}

			$.ajax({
					url: url,
					type: "POST",
					data: {k: k, password: pwd},
					dataType: 'json',
					beforeSend: function(){
						$('.send').append(' <div class="spinner-border spinner-border-sm" role="status"><span class="sr-only">Loading...</span></div>');
					},
					complete: function(){
						$('.send').find('.spinner-border').replaceWith('');
					},
					success: function(res){
						if(res.code == '1'){
							notify("success","提示",res.msg);
							$('#content').html('<div class="form-group row justify-content-center"><div class="alert alert-success" role="alert">重置密码成功！</div></div>');
						} else {
							notify("error","提示",res.msg);
						}
					}
			});
        });

        function notify(icon, title, content){
            $.toast({
                heading: title,
                text: content,
                showHideTransition: 'slide',
                icon: icon,
                position: 'top-right',
            })
            }
        </script>

    </body>
</html>